{{ define "main" }}

    {{ $cfg := (site.Params.node) }}
    {{ $tabsID := ((printf "node-tabs-%s" (.File.UniqueID)) | md5) }}
    {{ $changelog := (path.Join (.File.Dir) "changelog.md") }}

    {{ (partial "breadcrumb" .) }}

    <article>
      <header>
          {{ if ($cfg.cover.enabled) }}
            <div class="node-cover mb-3">
                {{ (partial "module/node/cover/02" .) }}
            </div>
          {{ end }}
        <div class="node-title">
          <h1 class="text-center">{{ (.Title) }}</h1>
        </div>
      </header>
      <footer>
        <ul class="list-inline text-center text-body-secondary small">
            {{ with (.Params.date) }}
              <li class="list-inline-item">
                <time datetime='{{ (.UTC.Format "2006-01-02T15:04:05Z07:00") }}' data-fn="date-local">
                    {{ (.UTC.Format "2006/01/02 15:04:05 MST") }}
                </time>
              </li>
            {{ end }}
            {{ with (.Params.complexity) }}
              <li class="list-inline-item">&bull;</li>
              {{ with (eq . "0") }}
                <li class="list-inline-item text-success"
                    data-bs-tooltip data-bs-title='{{ (i18n "complexity") }}: {{ (i18n "complexity-0") }}'>
                  <i class="far fa-face-smile fa-fw"></i>
                </li>
              {{ end }}
              {{ with (eq . "1") }}
                <li class="list-inline-item text-warning"
                    data-bs-tooltip data-bs-title='{{ (i18n "complexity") }}: {{ (i18n "complexity-1") }}'>
                  <i class="far fa-face-meh fa-fw"></i>
                </li>
              {{ end }}
              {{ with (eq . "2") }}
                <li class="list-inline-item text-danger"
                    data-bs-tooltip data-bs-title='{{ (i18n "complexity") }}: {{ (i18n "complexity-2") }}'>
                  <i class="far fa-face-frown fa-fw"></i>
                </li>
              {{ end }}
            {{ end }}
        </ul>
      </footer>
      <ul class="nav nav-tabs mb-3" id="node-tabs-{{ ($tabsID) }}" data-fn="node-tabs" role="tablist">
        <li class="nav-item" role="presentation" data-bs-tooltip data-bs-title='{{ (i18n "home") }}'>
          <button class="nav-link active" id="tab-main-home" type="button" role="tab"
                  data-bs-toggle="tab" data-bs-target="#tab-pane-main-home"
                  aria-controls="tab-pane-main-home" aria-selected="true" aria-label='{{ (i18n "home") }}'>
            <i class="fas fa-home fa-fw"></i>
          </button>
        </li>
          {{ if ($cfg.tabs.source.enabled) }}
            <li class="nav-item" role="presentation" data-bs-tooltip data-bs-title='{{ (i18n "source_code") }}'>
              <button class="nav-link" id="tab-main-source" type="button" role="tab"
                      data-bs-toggle="tab" data-bs-target="#tab-pane-main-source"
                      aria-controls="tab-pane-main-source" aria-selected="false" aria-label='{{ (i18n "source_code") }}'>
                <i class="fas fa-code fa-fw"></i>
              </button>
            </li>
          {{ end }}
          {{ if (and ($cfg.tabs.changelog.enabled) (fileExists ($changelog))) }}
            <li class="nav-item" role="presentation" data-bs-tooltip data-bs-title='{{ (i18n "changelog") }}'>
              <button class="nav-link" id="tab-main-changelog" type="button" role="tab"
                      data-bs-toggle="tab" data-bs-target="#tab-pane-main-changelog"
                      aria-controls="tab-pane-main-changelog" aria-selected="false" aria-label='{{ (i18n "changelog") }}'>
                <i class="far fa-clock fa-fw"></i>
              </button>
            </li>
          {{ end }}
          {{ if ($cfg.tabs.info.enabled) }}
            <li class="nav-item" role="presentation" data-bs-tooltip data-bs-title='{{ (i18n "info") }}'>
              <button class="nav-link" id="tab-main-info" type="button" role="tab"
                      data-bs-toggle="tab" data-bs-target="#tab-pane-main-info"
                      aria-controls="tab-pane-main-info" aria-selected="false" aria-label='{{ (i18n "info") }}'>
                <i class="fas fa-info fa-fw"></i>
              </button>
            </li>
          {{ end }}
          {{ if ($cfg.tabs.comments.enabled) }}
              {{ with (.Params.comments) }}
                <li class="nav-item" role="presentation" data-bs-tooltip data-bs-title='{{ (i18n "comments") }}'>
                  <button class="nav-link" id="tab-main-comments" type="button" role="tab"
                          data-bs-toggle="tab" data-bs-target="#tab-pane-main-comments"
                          aria-controls="tab-pane-main-comments" aria-selected="false" aria-label='{{ (i18n "comments") }}'>
                    <i class="far fa-comments fa-fw"></i>
                  </button>
                </li>
              {{ end }}
          {{ end }}
          {{ if (.IsTranslated) }}
            <li class="nav-item" role="presentation" data-bs-tooltip data-bs-title='{{ (i18n "languages") }}'>
              <button class="nav-link" id="tab-main-languages" type="button" role="tab"
                      data-bs-toggle="tab" data-bs-target="#tab-pane-main-languages"
                      aria-controls="tab-pane-main-languages" aria-selected="false" aria-label='{{ (i18n "languages") }}'>
                <i class="fas fa-language fa-fw"></i>
              </button>
            </li>
          {{ end }}
          {{ if ($cfg.tabs.share.enabled) }}
            <li class="nav-item ms-auto" role="presentation" data-bs-tooltip data-bs-title='{{ (i18n "share") }}'>
              <button class="nav-link" id="tab-main-share" type="button" role="tab"
                      data-bs-toggle="tab" data-bs-target="#tab-pane-main-share"
                      aria-controls="tab-pane-main-share" aria-selected="false" aria-label='{{ (i18n "share") }}'>
                <i class="fas fa-share fa-fw"></i>
              </button>
            </li>
          {{ end }}
      </ul>
      <div class="tab-content">
        <div class="tab-pane show active" id="tab-pane-main-home" role="tabpanel" aria-labelledby="tab-main-home" tabindex="0">
          <div class="node-body">
              {{ if (in (.Params.categories) "inDev") }}
                  {{ (partial "function/alert" (dict
                  "type" "warning"
                  "icon" "fas fa-edit"
                  "msg" (i18n "alert.in_dev")
                  )) }}
              {{ end }}
              {{ if (in (.Params.categories) "inHistory") }}
                  {{ (partial "function/alert" (dict
                  "type" "warning"
                  "icon" "fas fa-clock-rotate-left"
                  "msg" (i18n "alert.in_history")
                  )) }}
              {{ end }}
              {{ if (in (.Params.categories) "opinion") }}
                  {{ (partial "function/alert" (dict
                  "type" "warning"
                  "icon" "fas fa-user-graduate"
                  "msg" (i18n "alert.opinion")
                  )) }}
              {{ end }}

              {{ (partial "module/node/toc" .) }}

              {{ (.Content) }}

              {{ (partial "module/node/sources" .) }}
          </div>
        </div>
          {{ if ($cfg.tabs.source.enabled) }}
            <div class="tab-pane" id="tab-pane-main-source" role="tabpanel" aria-labelledby="tab-main-source" tabindex="0">
              <div class="node-body node-source">
                  {{ (highlight (readFile (.File.Path)) "md") }}
              </div>
            </div>
          {{ end }}
          {{ if (and ($cfg.tabs.changelog.enabled) (fileExists ($changelog))) }}
            <div class="tab-pane" id="tab-pane-main-changelog" role="tabpanel" aria-labelledby="tab-main-changelog" tabindex="0">
              <div class="node-body">
                  {{ ((readFile ($changelog)) | markdownify) }}
              </div>
            </div>
          {{ end }}
          {{ if ($cfg.tabs.info.enabled) }}
            <div class="tab-pane" id="tab-pane-main-info" role="tabpanel" aria-labelledby="tab-main-info" tabindex="0">
              <div class="node-body">
                <div class="row row-cols-1 row-cols-lg-2 g-3">
                    {{ if ($cfg.tabs.info.categories.enabled) }}
                      <div class="col">
                          {{ (partial "module/node/tabs/info/categories" .) }}
                      </div>
                    {{ end }}
                    {{ if ($cfg.tabs.info.tags.enabled) }}
                      <div class="col">
                          {{ (partial "module/node/tabs/info/tags" .) }}
                      </div>
                    {{ end }}
                    {{ if ($cfg.tabs.info.authors.enabled) }}
                      <div class="col">
                          {{ (partial "module/node/tabs/info/authors" .) }}
                      </div>
                    {{ end }}
                    {{ if ($cfg.tabs.info.related.enabled) }}
                      <div class="col">
                          {{ (partial "module/node/tabs/info/related" .) }}
                      </div>
                    {{ end }}
                    {{ if ($cfg.tabs.info.meta.enabled) }}
                      <div class="col">
                          {{ (partial "module/node/tabs/info/meta" .) }}
                      </div>
                    {{ end }}
                    {{ if ($cfg.tabs.info.stats.enabled) }}
                      <div class="col">
                          {{ (partial "module/node/tabs/info/stats" .) }}
                      </div>
                    {{ end }}
                </div>
              </div>
            </div>
          {{ end }}
          {{ if ($cfg.tabs.comments.enabled) }}
              {{ with (.Params.comments) }}
                <div class="tab-pane" id="tab-pane-main-comments" role="tabpanel" aria-labelledby="tab-main-comments" tabindex="0">
                  <div class="node-body">
                      {{ (partial "module/node/tabs/comments" .) }}
                  </div>
                </div>
              {{ end }}
          {{ end }}
          {{ if (.IsTranslated) }}
            <div class="tab-pane" id="tab-pane-main-languages" role="tabpanel" aria-labelledby="tab-main-languages" tabindex="0">
                {{ (partial "module/node/tabs/languages" .) }}
            </div>
          {{ end }}
          {{ if ($cfg.tabs.share) }}
            <div class="tab-pane" id="tab-pane-main-share" role="tabpanel" aria-labelledby="tab-main-share" tabindex="0">
                {{ (partial "module/node/tabs/share" .) }}
            </div>
          {{ end }}
      </div>
    </article>

{{ end }}
